import { DictEnum } from '@vben/constants';

import { SensitiveText } from '#/components/text';

export const basicInfoSchema: DetailsModalSchemaGetter = () => [
  {
    label: '姓名',
    fieldName: 'name',
    copy: true,
  },
  {
    label: '企业名称',
    fieldName: 'companyName',
    copy: true,
    accessCode: 'company:manager:query',
    url: (info: any) => `/company/manage/details/${info.companyId}`,
  },
  {
    label: '部门',
    fieldName: 'departmentId',
    dictEnum: DictEnum.AUDIENCE_DEPARTMENT,
  },
  {
    label: '职位',
    fieldName: 'positionId',
    dictEnum: DictEnum.AUDIENCE_POSITION,
  },
  {
    label: '手机号',
    fieldName: 'mobile',
    slots: {
      default: (info) => {
        return (
          <SensitiveText
            access-page={2}
            employee-id={info.id}
            text={info.mobile}
            type={1}
          />
        );
      },
    },
  },
  {
    label: '备用手机号',
    fieldName: 'secondMobile',
    slots: {
      default: (info) => {
        return (
          <SensitiveText
            access-page={2}
            employee-id={info.id}
            text={info.secondMobile}
            type={3}
          />
        );
      },
    },
  },
  {
    label: '邮箱',
    fieldName: 'email',
    slots: {
      default: (info) => {
        return (
          <SensitiveText
            access-page={2}
            employee-id={info.id}
            text={info.email}
            type={2}
          />
        );
      },
    },
  },
  {
    label: '微信号',
    fieldName: 'wechatNo',
  },
  {
    label: '跟进人',
    fieldName: 'followUpName',
  },
  {
    label: '所在地区',
    fieldName: 'countryCode',
    span: 2,
    copy: (info: any) => {
      if (info.countryCode !== '00') {
        return `${info.address} ${info.countryName}`;
      }

      return `${info.countryName}${info.provinceName}${info.cityName}${info.districtName}${info.address}`;
    },
    slots: {
      default: (info) => {
        if (info.countryCode !== '00') {
          return (
            <span>
              {info.address} {info.countryName}
            </span>
          );
        }
        return (
          <span>
            {info.countryName}
            {info.provinceName}
            {info.cityName}
            {info.districtName}
            {info.address}
          </span>
        );
      },
    },
  },
  {
    label: '人员标签',
    fieldName: 'labels',
    custom: true,
    span: 2,
  },
  {
    label: '备注',
    fieldName: 'remark',
    textWrap: true,
    span: 2,
  },
];
